package uw10.app.display;

public interface TweenHandler
{
	boolean doTweens();
	
	public static class TweenRunnable implements Runnable
	{
		private TweenHandler handler;
		private long period;
		
		private boolean running;
		
		public TweenRunnable(TweenHandler handler, long period)
		{
			this.handler = handler;
			this.period = period;
			
			running = false;
		}
		
		public synchronized void doTweens()
		{
			if (! running)
			{
				running = true;
				new Thread(this).start();
			}
		}
		
		public void run()
		{
			while (true)
			{
				if (handler.doTweens())
				{
					try
					{
						Thread.sleep(period);
					}
					catch (Exception e) { }
				}
				else break;
			}
			
			running = false;
		}
	}
}
